package com.qf.controller;

import com.qf.pojo.reqVo.CourseReq;
import com.qf.pojo.resVo.BaseResult;
import com.qf.service.ShopCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 购物车controller
 */
@RequestMapping("/shop")
@RestController
public class ShopCardController {
    @Autowired
    ShopCardService shopCardService;

    /**
     * 添加购物车
     * @param courseReq
     * @param request
     * @return
     */
    @RequestMapping("/addShopCard")
    public BaseResult addShopCard(@RequestBody CourseReq courseReq, HttpServletRequest request){
        return shopCardService.addShopCard(courseReq,request);
    }

    /**
     * 查询该用户的购物车信息
     * @param request
     * @return
     */
    @RequestMapping("/findShopCardByToken")
    public BaseResult findShopCardByToken(HttpServletRequest request){
        return shopCardService.findShopCardByToken(request);
    }
    /**
     * 删除购物车的某个课程
     */
    @RequestMapping("/delShop")
    public BaseResult delShop(@RequestBody CourseReq courseReq, HttpServletRequest request){
        return shopCardService.delShop(courseReq,request);
    }
}
